package com.yk.web.controller;

import java.util.List;

import com.yk.course.domain.CoursePeriodChild;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yk.common.annotation.Log;
import com.yk.common.enums.BusinessType;
import com.yk.course.service.ICoursePeriodChildService;
import com.yk.common.core.controller.BaseController;
import com.yk.common.core.domain.AjaxResult;
import com.yk.common.utils.poi.ExcelUtil;
import com.yk.common.core.page.TableDataInfo;

/**
 * 课程详情学生Controller
 * 
 * @author xufei
 * @date 2025-05-03
 */
@Controller
@RequestMapping("/course/coursePeriodChild")
public class CoursePeriodChildController extends BaseController
{
    private String prefix = "course/coursePeriodChild";

    @Autowired
    private ICoursePeriodChildService coursePeriodChildService;

    @RequiresPermissions("course:coursePeriodChild:view")
    @GetMapping()
    public String coursePeriodChild()
    {
        return prefix + "/coursePeriodChild";
    }

    /**
     * 查询课程详情学生列表
     */
    @RequiresPermissions("course:coursePeriodChild:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CoursePeriodChild coursePeriodChild)
    {
        startPage();
        List<CoursePeriodChild> list = coursePeriodChildService.selectCoursePeriodChildList(coursePeriodChild);
        return getDataTable(list);
    }

    /**
     * 导出课程详情学生列表
     */
    @RequiresPermissions("course:coursePeriodChild:export")
    @Log(title = "课程详情学生", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CoursePeriodChild coursePeriodChild)
    {
        List<CoursePeriodChild> list = coursePeriodChildService.selectCoursePeriodChildList(coursePeriodChild);
        ExcelUtil<CoursePeriodChild> util = new ExcelUtil<CoursePeriodChild>(CoursePeriodChild.class);
        return util.exportExcel(list, "课程详情学生数据");
    }

    /**
     * 新增课程详情学生
     */
    @RequiresPermissions("course:coursePeriodChild:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存课程详情学生
     */
    @RequiresPermissions("course:coursePeriodChild:add")
    @Log(title = "课程详情学生", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CoursePeriodChild coursePeriodChild)
    {
        return toAjax(coursePeriodChildService.insertCoursePeriodChild(coursePeriodChild));
    }

    /**
     * 修改课程详情学生
     */
    @RequiresPermissions("course:coursePeriodChild:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CoursePeriodChild coursePeriodChild = coursePeriodChildService.selectCoursePeriodChildById(id);
        mmap.put("coursePeriodChild", coursePeriodChild);
        return prefix + "/edit";
    }

    /**
     * 修改保存课程详情学生
     */
    @RequiresPermissions("course:coursePeriodChild:edit")
    @Log(title = "课程详情学生", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CoursePeriodChild coursePeriodChild)
    {
        return toAjax(coursePeriodChildService.updateCoursePeriodChild(coursePeriodChild));
    }

    /**
     * 删除课程详情学生
     */
    @RequiresPermissions("course:coursePeriodChild:remove")
    @Log(title = "课程详情学生", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(coursePeriodChildService.deleteCoursePeriodChildByIds(ids));
    }
}
